package Week3.J0504;

// topK问题

import java.util.Arrays;
import java.util.Scanner;

class Orange {
    int sour;
    int sweet;
    public Orange(){};

    public Orange(int sour, int sweet) {
        this.sour = sour;
        this.sweet = sweet;
    }
}


public class chika和蜜柑_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        Orange[] orange = new Orange[n];
        for (int i = 0; i < n; i++) {
            orange[i] = new Orange();
            orange[i].sour = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            orange[i].sweet = scanner.nextInt();
        }

        Arrays.sort(orange, (x, y) -> {
            if (x.sweet == y.sweet) return x.sour - y.sour;
            return y.sweet - x.sweet;
        });

        long max = 0; long min = 0;
        for (int i = 0; i < k; i++) {
            max += orange[i].sweet;
            min += orange[i].sour;
        }

        System.out.println(min+" "+max);
    }
}
